package com.wanglei.framework.service

import com.wanglei.framework.common.TService
import com.wanglei.framework.dao.WordCountDao
import org.apache.spark.rdd.RDD

class WordCountService extends TService {

  private val wordCountDao = new WordCountDao

  def dataProcess(): RDD[(String, Int)] = {
    val lines: RDD[String] = wordCountDao.readFile("datas/1.txt")
    val words: RDD[String] = lines.flatMap(_.split(" "))
    val wordToOne: RDD[(String, Int)] = words.map(word => (word, 1))
    val res: RDD[(String, Int)] = wordToOne.reduceByKey(_ + _)
    res
  }

}
